package com.fjh.controller;

import com.fjh.anno.Log;
import com.fjh.domain.SysRole;
import com.fjh.service.SysRoleService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@Api(tags = "角色管理")
@RequestMapping("sys/role")
public class SysRoleController {

    @Autowired
    private SysRoleService sysRoleService;

    @GetMapping("list")
    @ApiOperation("加载所有的角色列表")
    @PreAuthorize("hasAuthority('sys:role:list')")
    @Log(operation = "加载所有的角色列表")
    public ResponseEntity<List<SysRole>> loadAllRole(){
        List<SysRole> list = sysRoleService.list();
        return ResponseEntity.ok(list);
    }
}
